//
// Created by Administrator on 2021/8/3.
//
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string>

using namespace std;

class Solution {
public:
    vector<string> findRelativeRanks(vector<int> &score) {
        vector<int> sorted_score(score);
        sort(sorted_score.rbegin(), sorted_score.rend());
        unordered_map<int, string> um;
        vector<string> ans;
        if (sorted_score.size() == 1) {
            ans.emplace_back("Gold Medal");
            return ans;
        } else if (sorted_score.size() == 2) {
            um[sorted_score[0]] = "Gold Medal";
            um[sorted_score[1]] = "Silver Medal";
            ans.emplace_back(um[score[0]]);
            ans.emplace_back(um[score[1]]);
        } else {
            um[sorted_score[0]] = "Gold Medal";
            um[sorted_score[1]] = "Silver Medal";
            um[sorted_score[2]] = "Bronze Medal";
            for (int i = 3; i < sorted_score.size(); ++i) {
                um[sorted_score[i]] = to_string(i + 1);
            }
            for (int &i : score) {
                ans.emplace_back(um[i]);
            }
        }
        return ans;
    }
};

class Solution2 {
public:
    vector<string> findRelativeRanks(vector<int> &score) {
        vector<int> sorted_score(score);
        unordered_map<int, string> um;
        sort(sorted_score.rbegin(), sorted_score.rend());
        for (int i = 0; i < score.size(); ++i) {
            switch (i) {
                case 0:
                    um[sorted_score[i]] = "Gold Medal";
                    break;
                case 1:
                    um[sorted_score[i]] = "Silver Medal";
                    break;
                case 2:
                    um[sorted_score[i]] = "Bronze Medal";
                    break;
                default:
                    um[sorted_score[i]] = to_string(i + 1);
            }
        }
        vector<string> ans(score.size());
        for (int i = 0; i < score.size(); ++i) {
            ans[i] = um[score[i]];
        }
        return ans;
    }
};

int main() {
    // 如果成绩一样咋办
    vector<int> scores{10, 3, 8, 9, 4};
    Solution2 solution;
    auto ans = solution.findRelativeRanks(scores);
    for (auto &x:ans) {
        cout << x << endl;
    }
    return 0;
}
